package com.yksj.healthtalk.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.yksj.healthtalk.ui.R;

public class PhotoAlbumAdapter extends BaseAdapter {

	private final LayoutInflater mInflater;
	private int[] jsonArrays=null;
	
	public PhotoAlbumAdapter(Context mContext,int[] data) {
		this.jsonArrays=data;
		this.mInflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		
		return jsonArrays.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return jsonArrays[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder mHolder = null;
		if(mHolder==null){
			mHolder=new ViewHolder();
			convertView=mInflater.inflate(R.layout.photo_image_view, null);
			mHolder.mImageView=(ImageView) convertView.findViewById(R.id.photo_image_item);
			convertView.setTag(mHolder);
		}else{
		mHolder=(ViewHolder) convertView.getTag();
		}
		mHolder.mImageView.setBackgroundResource(jsonArrays[position]);
//		mImageLoader.displayImage(jsonArrays[position], mHolder.mImageView, mOptions);
		
		return convertView;
	}

	static class ViewHolder{
		private ImageView mImageView;
	}
	
}
